{% extends "layout/basic.html" %}
{% load static %}

{% block title %}
    用户登录
{% endblock %}

{% block css %}
    <link rel="stylesheet" href="{% static "css/account.css" %}">
    <style>
        .err_msg {
            height: 30px;
            color: red;
            position: absolute;
        }
    </style>
{% endblock %}

{% block content %}
    <div id="app">
        <div class="account">
            <h1 class="title">用户登录</h1>
            <form method="post">
                {% csrf_token %}
                {% for field in form %}
                    {% if field.label == "图片验证码" %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <div class="clearfix">
                                <div class="col-md-6" style="padding-left: 0">{{ field }}</div>
                                <div class="col-md-6">
                                    <img v-bind:src="image_code_url" alt="" @click="get_image_code">
                                </div>
                            </div>
                            <span v-show="{{ field.name }}_error"
                                  class="err_msg">[[ {{ field.name }}_error_msg ]]</span>
                            {#                展示由后端检验报错的信息#}
                            {% if sms_err_code == 100 %}
                                <div><span class="err_msg">{{ sms_errmsg }}</span></div>
                            {% endif %}
                        </div>

                    {% elif field.label == "uuid" %}
                        <label for="{{ field.id_for_label }}" style="display: none">{{ field.label }}</label>
                        <div style="display: none">{{ field }}</div>
                    {% else %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            <div>{{ field }}</div>
                            <span v-show="{{ field.name }}_error"
                                  class="err_msg">[[ {{ field.name }}_error_msg ]]</span>
                        </div>
                    {% endif %}
                {% endfor %}
                <div>
                    <span class="err_msg">{{ err_msg }}</span>
                </div>
                <div>
                    <div style="float: right">
                        <a href="{% url "login_sms" %}">忘记密码？</a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-3">
                        <button class="btn-primary" type="submit">登录</button>
                    </div>
                </div>


            </form>
        </div>
    </div>
{% endblock %}

{% block js %}
    <script src="{% static "js/vue-3.1.2.js" %}"></script>
    <script src="{% static "js/axios-0.18.0.min.js" %}"></script>
    <script src="{% static "js/common.js" %}"></script>
    <script src="{% static "js/login.js" %}"></script>
{% endblock %}